#include <iostream>
#include <algorithm>

using namespace std;

const int N = 3e4 + 10;

int n, m;
int q[N];
int res;

int main()
{
	cin >> n >> m;
	
	for (int i = 0; i < m; i ++ ) cin >> q[i];
	
	sort(q, q + m);
	
	
	
	for (int i = 0, j = m - 1; j >= i; j -- )
	{
		int t = q[i] + q[j];
		
		while (i < j && t <= n)
		{
			t += q[ ++ i];
		}
		
		res ++ ;
	}
	
	cout << res << endl;
	
	return 0; 	
	
} 
